import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:graduation_project/books/cartoon_leader.dart';
import 'dart:convert' as convert;

import 'package:graduation_project/common/global.dart';

class cartoon_list_double extends StatefulWidget {
  cartoon_list_double({Key key, this.cartoon_list}) : super(key: key);
  List cartoon_list = [];
  @override
  State<cartoon_list_double> createState() => _cartoon_list_doubleState();
}

class _cartoon_list_doubleState extends State<cartoon_list_double> {
  //  cartoon_list => null;

  // List cartoon_list=widget.cartoon_list;
  @override
  Widget build(BuildContext context) {
    // widget.cartoon_list = cartoon_list1;

    return Wrap(
      // spacing: 10,
      children: widget.cartoon_list.map((e) {
        // print(e['cartoon_tage'][0]);
        // var res = convert.jsonDecode(e['cartoon_tage']);
        // print(res);

        return GestureDetector(
          onTap: () {
            print(e['cartoon_id']);
            // print(_scrollController);
            // books_bodys
            Navigator.push(context, MaterialPageRoute(builder: (_) {
              return cartoon_leader(
                cartoon_id: e['cartoon_id'],
              );
            }));
          },
          child: Container(
            decoration: new BoxDecoration(
              color: Color.fromRGBO(255, 255, 255, 1),
              // color: Colors.red,
              // 设置四周圆角，角度
              borderRadius: BorderRadius.all(Radius.circular(4.0)),
              border: new Border.all(color: Colors.black38, width: 0.2),
            ),
            margin: EdgeInsets.only(left: 4, right: 4, bottom: 20),
            width: 180,
            height: 300,
            // color: Colors.red,
            child: Column(
              children: [
                Container(
                  height: 240,
                  width: 180,
                  child: Image(
                      fit: BoxFit.fill,
                      image: NetworkImage(e['cartoon_leader_image'])),
                ),
                // Expanded(child: SizedBox()),
                Container(
                  margin: EdgeInsets.only(top: 8, left: 8, bottom: 4),
                  width: 180,
                  child: Text(
                    e['cartoon_name'],
                    style: TextStyle(fontSize: 14),
                  ),
                ),
                Row(
                  children: [
                    Container(
                      margin: EdgeInsets.only(
                        top: 4,
                        left: 8,
                      ),
                      width: 120,
                      child: Text(
                        Global.getTageName(e['cartoon_tage']),
                        style: TextStyle(fontSize: 12, color: Colors.black54),
                      ),
                    ),
                  ],
                )
              ],
            ),
          ),
        );
      }).toList(),
    );
  }
}
